<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
	<script src="js/jquery.min.js"></script>
</head>
<body>
<button onclick="create()">创建数据库</button>
<button onclick="insert()">插入一条数据</button>
<button onclick="deletes()">删除一条数据</button>
<button onclick="select()">查询</button>
<button onclick="media()">播放声音</button>
<button onclick="getNetType()">获取网络类型</button>
<br><br>

<form action="" method="post">

    <input type="file" name="mufile">
    <input type="submit" name="mufile">
</form>

<br><br>

<button onclick="getBluetooth()">获取蓝牙列表</button>
<button onclick="bluetoothConnect()">连接打印机</button>
<button onclick="bluetoothStatus()">获取打印机状态</button>
<button onclick="testPrint()">测试打印</button>
<div id="blueList">这里显示蓝牙列表</div>


</body>
<script>

        // 下面两个方法对应SqlService.java中的两个方法
        // app.exeSql():这个方法执行增删改
        // app.select(): 查询操作
        function testPrint(){
            bluetooth.print(90, 48 + 100, "测试打印", 3, 0, 0, false, false)
        }
        function bluetoothStatus(){
            var info=bluetooth.printInfo();
            alert(info)
        }
        function bluetoothConnect(){
            bluetooth.connect('F2:45:4F:4D:F7:1C')
        }
        function getBluetooth(){
            var json=bluetooth.blueList()
            $("#blueList").html(json)
        }

        function getNetType(){
            var typ=tools.netType();
            alert(typ)
        }
        function useCamera(){
            camera.usePic();
        }
        function selectCamera(){
            camera.selectPic();
        }

        function create(){
            // 创建表格，表如果已存在则不会执行，表不存在才会执行创建
            app.exeSql("create table user(id integer primary key autoincrement,name varchar(50),age integer)")
        }
        function insert(){
            var res=app.exeSql("insert into user(name,age)values('张飞',26)")
            var res=app.exeSql("insert into user(name,age)values('关羽',26)")
            var res=app.exeSql("insert into user(name,age)values('刘备',31)")
            alert(res)
        }

        function deletes(){
            var res=app.exeSql("delete from user where name='关羽'")
            alert(res)
        }


        function select(){
            var json=app.select("select id,name,age from user")
            alert(json)
        }
        function media(){
            // 参数传assets文件夹下面的音频文件名
            playService.play("2.mp3");
        }
    </script>
</html>
